package com.lws.applicationlifecycle;

import android.app.Application;

public class LifeCycleApplication extends Application {

    private final AppLifeCycle appLifeCycle = new AppLifeCycle();

    public AppLifeCycle getAppLifeCycle() {
        return appLifeCycle;
    }

    /**
     * 提供AppLifeCycle服务
     */
    @Override
    public Object getSystemService(String name) {
        if (name.equals(AppLifeCycle.NAME)) {
            return appLifeCycle;
        }
        return super.getSystemService(name);
    }


    /**
     * 通知观察者 onCreate
     */
    @Override
    public void onCreate() {
        super.onCreate();
        appLifeCycle.onCreate();
    }

    /**
     * 通知观察者 onTerminate
     */
    @Override
    public void onTerminate() {
        super.onTerminate();
        appLifeCycle.onTerminate();
    }
}
